package com.robot.controller;

import com.robot.model.User;
import com.robot.service.UserService;
import com.robot.vo.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2019/6/16
 * Time: 16:12
 * PROJECT：robot
 * PACKAGE: com.robot
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/userList")
    public @ResponseBody
    ResponseMessage userList(){
      return   userService.userList();
    }


    @RequestMapping("/login")
    public ModelAndView login(User User){
        ModelAndView modelAndView=new ModelAndView();
        //这里会有一系列的 用户名空值，密码空值 等等的判断

       ResponseMessage responseMessage =userService.checkUser(User);
       if(!responseMessage.isSuccess()){
            //也要返回当前页面，并且给出提示信息，并且把已经填写的值回写到页面
       }
        //做一些缓存的处理，返回网站的首页，或者某一个页面
        return modelAndView;
    }
}
